package com.etc.test4;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

/**
 * @author MaZheng
 * @since 2020/12/24 - 9:16
 */

@Aspect
@EnableAspectJAutoProxy(proxyTargetClass = false)
@Configuration
public class AOPHandle {

    @Before("execution(* com.etc.test4.dao.*.*(..))")
    public void beforadvice() {
        System.out.println("-----before------------");
    }

    @AfterReturning("execution(* com.etc.test4.dao.*.*(..))")
    public void AfterReturning() {
        System.out.println("-----AfterReturning------------");
    }


    @AfterThrowing(value = "execution(* com.etc.test4.dao.*.*(..))", throwing = "e")
    public void AfterThrowing(JoinPoint point, Throwable e) {
        System.out.println("-----AfterThrowing------------");
    }

    @After("execution(* com.etc.test4.dao.*.*(..))")
    public void afteradvice() {

        System.out.println("-----afteradvice------------");
    }


    @Around("execution(* com.etc.test4.dao.*.*(..))")
    public void Around(ProceedingJoinPoint jp) throws Throwable {
        System.out.println("-----Around befor------------");
        jp.proceed();
        System.out.println("-----Around after------------");
    }
}
